#ifndef ALLOWANCE_TYPE_DETAIL_STRUCT_HH
#define ALLOWANCE_TYPE_DETAIL_STRUCT_HH 1


#include <string>
#include <iostream>
#include <vector>
#include "otl8.hpp"

static const char*  allowance_type_detail_struct_s = "SELECT PARENT_ID, CHILD_ID, NAME, ALLOWANCE_LIMIT FROM ALLOWANCE_TYPE_DETAIL_STRUCT";

static const char*  allowance_type_detail_struct_i = "INSERT INTO ALLOWANCE_TYPE_DETAIL_STRUCT ( PARENT_ID, CHILD_ID, NAME, ALLOWANCE_LIMIT )VALUES(:f1<int>, :f2<int>, :f3<char[128]>, :f4<float>)";

static const char* allowance_type_detail_struct_c = "CREATE TABLE ALLOWANCE_TYPE_DETAIL_STRUCT ( PARENT_ID INTEGER , CHILD_ID INTEGER , NAME VARCHAR(128) , ALLOWANCE_LIMIT FLOAT )";
class allowance_type_detail_struct
{



public:
allowance_type_detail_struct():_parent_id(0), _child_id(0), _name(""), _allowance_limit(0){_select=allowance_type_detail_struct_s;_insert=allowance_type_detail_struct_i;_create=allowance_type_detail_struct_c;}


allowance_type_detail_struct(int a__parent_id, int a__child_id, std::string a__name, float a__allowance_limit):_parent_id(a__parent_id) , _child_id(a__child_id) , _name(a__name) , _allowance_limit(a__allowance_limit) {_select=allowance_type_detail_struct_s;_insert=allowance_type_detail_struct_i;_create=allowance_type_detail_struct_c;}


int parent_id(){return  _parent_id;}
void set_parent_id(int a__parent_id){ _parent_id = a__parent_id;}


int child_id(){return  _child_id;}
void set_child_id(int a__child_id){ _child_id = a__child_id;}


std::string name(){return  _name;}
void set_name(std::string a__name){ _name = a__name;}


float allowance_limit(){return  _allowance_limit;}
void set_allowance_limit(float a__allowance_limit){ _allowance_limit = a__allowance_limit;}


allowance_type_detail_struct & operator=( const allowance_type_detail_struct & x)
{
	_parent_id =  x._parent_id;
	_child_id =  x._child_id;
	_name =  x._name;
	_allowance_limit =  x._allowance_limit;
	return *this;
}


bool operator==( const allowance_type_detail_struct & x)
{
	return 	_parent_id ==  x._parent_id &&
	_child_id ==  x._child_id &&
	_name ==  x._name &&
	_allowance_limit ==  x._allowance_limit;
}


friend std::istream& operator >> (std::istream& ist, allowance_type_detail_struct & t)
{
	if (!(ist >> t._parent_id)) return ist;
	if (!(ist >> t._child_id)) return ist;
	if (!(ist >> t._name)) return ist;
	if (!(ist >> t._allowance_limit)) return ist;

	return ist;
}

friend std::ostream& operator << (std::ostream& ost, allowance_type_detail_struct & t)
{
	ost << t._parent_id << " ";
	ost << t._child_id << " ";
	ost << t._name << " ";
	ost << t._allowance_limit << " ";

	return ost;
}

/*
friend otl_stream& operator >> (otl_stream& ist, allowance_type_detail_struct & t)
{
	ist >> t._parent_id;
	ist >> t._child_id;
	ist >> t.buf; t._name=(const char*)t.buf;
	ist >> t._allowance_limit;

	return ist;
}

friend otl_stream& operator << (otl_stream& ost, allowance_type_detail_struct & t)
{
	ost << t._parent_id ;
	ost << t._child_id ;
	ost << t._name.c_str() ;
	ost << t._allowance_limit ;

	return ost;
}
*/

std::string select_stmt() { return _select; }
std::string insert_stmt() { return _insert; }
std::string create_stmt() { return _create; }


private:

	int	_parent_id;
	int	_child_id;
	std::string	_name;
	float	_allowance_limit;
	std::string _create;
	std::string _select;
	std::string _insert;
char buf[128];
};
#endif
